package cn.psvmc.cxzapi.util;

import cn.psvmc.cxzapi.model.goods.TGoodsExcelVo;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ywx
 * @className ExcelUtil
 * @description
 * @date 2024/12/14 22:19
 **/
public class ExcelUtil {

    //读取商家侧编码
    public static List<String> readExcel(String filePath) {
        List<String> list = new ArrayList<>();
        EasyExcel.read(filePath, TGoodsExcelVo.class, new AnalysisEventListener<TGoodsExcelVo>() {
            @Override
            public void invoke(TGoodsExcelVo o, AnalysisContext analysisContext) {
                list.add(o.getGoodsCode());
            }

            @Override
            public void doAfterAllAnalysed(AnalysisContext analysisContext) {
            }
        }).sheet().doRead();
        return list;
    }
}
